import axios from 'axios'
import store from '@/store/'

const request = axios.create({
  baseURL: 'http://api-toutiao-web.itheima.net/'
})

// 请求拦截器
request.interceptors.request.use(config => {
  const {
    user
  } = store.state
  if (user) {
    config.headers.Authorization = `Bearer ${store.state.user.token}`
  }
  return config
})

// 响应拦截器

// 导出
export default request
